﻿using Dapper;
using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using System.Threading.Tasks;

namespace SXFramWork.Core
{
    public interface ISql
    {
        /// <summary>
        /// 执行增加，修改，删除使用【dapper】
        /// </summary>
        /// <param name="sql">sql语句</param>
        /// <param name="param">参数</param>
        /// <param name="unitOfWork">工作单元</param>
        /// <returns></returns>
        Task<int> ExecuteAsync(string sql, object param = null, IUnitOfWork unitOfWork = null);
        /// <summary>
        /// 增加，修改，删除 In【dapper】
        /// </summary>
        /// <param name="sql">sql语句</param>
        /// <param name="param">参数</param>
        /// <param name="unitOfWork">工作单元</param>
        /// <returns></returns>
        Task<int> ExecuteaInAync(string sql, object param, IUnitOfWork unitOfWork = null);
        /// <summary>
        /// 执行返回第一行第一列【dapper】
        /// </summary>
        /// <param name="sql">sql语句</param>
        /// <param name="param">参数</param>
        /// <param name="unitOfWork">工作单元</param>
        /// <returns></returns>
        Task<object> ExecuteScalarAsync(string sql, object param = null, IUnitOfWork unitOfWork = null);
        /// <summary>
        /// 同时查询多张表数据（高级查询）
        /// "select *from A;select *from B";【dapper】
        /// </summary>
        /// <param name="sql">sql语句</param>
        /// <param name="param">参数</param>
        /// <param name="unitOfWork">工作单元</param>
        /// <returns></returns>
        Task<SqlMapper.GridReader> QueryMultipleAsync(string sql, object param = null, IUnitOfWork unitOfWork = null);
        /// <summary>
        /// 批量插入【dapper】
        /// </summary>
        /// <param name="sql">sql语句</param>
        /// <param name="list">要插入的集合</param>
        /// <param name="unitOfWork"></param>
        /// <returns></returns>
        Task<int> AddDataListAsync(string sql, object list,IUnitOfWork unitOfWork = null);
        /// <summary>
        /// 查询返回string
        /// </summary>
        /// <param name="sql">sql语句</param>
        /// <param name="unitOfWork">工作单元</param>
        /// <param name="param">sql参数</param>
        /// <returns></returns>
        Task<string> GetStrAsync(string sql,object param=null,IUnitOfWork unitOfWork=null);
    }
}
